package sunbao.ido.experimentalField.listener;

import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * \* User: MeiZhongHao
 * \* Date: 2018-11-13
 * \* Time: 18:07
 * \* Description:
 * \
 */
@Component
public class AnnotationRegisterListener {

    /**
     * 注册监听实现方法
     * @param userRegisterEvent 用户注册事件
     */
    @EventListener
    public void register(UserRegisterEvent userRegisterEvent)
    {
        //获取注册用户对象
        UserBean user = userRegisterEvent.getUser();
        //输出注册用户信息
        System.out.println("@EventListener注册信息，用户名："+user.getName()+"，密码："+user.getPassword());
    }

    @EventListener
    public void sendMail(UserRegisterEvent userRegisterEvent)
    {
        //获取注册用户对象
        UserBean user = userRegisterEvent.getUser();
        //输出注册用户信息
        System.out.println("@EventListener发布邮件，用户名："+user.getName()+"，密码："+user.getPassword());
    }

}